package cn.com.dhc.danlu.delegate.delegate.coupon;

import java.util.List;

import cn.com.dhc.danlu.delegate.callback.ICouponListView;
import cn.com.dhc.danlu.delegate.delegate.list.BaseListDataDelegate;
import cn.com.dhc.danlu.dlware.OperatorUtils;
import cn.com.hd.mall.web.webservices.entity.BaseResponse;
import cn.com.hd.mall.web.webservices.entity.freedom.request.coupon.GetActivityListReq;
import cn.com.hd.mall.web.webservices.entity.freedom.response.coupon.ObtainDealersCouponList;
import rx.Observable;

import static cn.com.dhc.danlu.dlware.global.DanluApplication.agent;

/**
 * User: Geek_Soledad(wuhaiyang@danlu.com)
 * Date: 2016-09-22
 * Time: 16:21
 * Description: 领券中心 & 抢经销商红包
 */
public class DealersCouponObtainDelegate extends BaseListDataDelegate<ICouponListView> {

    @Override
    protected Observable createRequestObservable (int page) {
        GetActivityListReq params = (GetActivityListReq) mViewBridge.createFetchReqParams ();
        params.setPage (page);
        params.setRows (mPageSize);
        params.setToken (agent.getToken ());
        return agent.getApi().getActivityList(params).compose(OperatorUtils.<ObtainDealersCouponList>defaultSchedulers());
    }

    @Override
    protected List excavateList (BaseResponse model) {
        return ((ObtainDealersCouponList) model).getActivityList ();
    }
}